package com.tony.pmp.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tony.pmp.common.utils.PageUtil;
import com.tony.pmp.common.utils.QueryUtil;
import com.tony.pmp.model.entity.SysDictEntity;
import com.tony.pmp.model.mapper.SysDictMapper;
import com.tony.pmp.server.service.SysDictService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: SysDictServiceImpl
 * @Auther: 皮蛋布丁
 * @Date: 2021/08/04/21:21
 * @Description:
 */
@Service("sysDictService")
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDictEntity> implements SysDictService {

    /**
    * @Description: queryPage 获取字典列表数据(分页)
    * @Param: [params]
    * @return: com.tony.pmp.common.utils.PageUtil
    * @Author: 皮蛋布丁
    * @Date: 2021/8/4 21:37
    */
    @Override
    public PageUtil queryPage(Map<String, Object> params) {
        String name = (String) params.get("name");

        IPage queryPage = new QueryUtil<SysDictEntity>().getQueryPage(params);

        //查询包装器
        QueryWrapper<SysDictEntity> wrapper = new QueryWrapper<SysDictEntity>()
                .like(StringUtils.isNotBlank(name),"name",name);
        IPage<SysDictEntity> page = this.page(queryPage,wrapper);

        return new PageUtil(page);
    }
}
